package com.example.plugin;

import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.http.cookie.GlobalCookieManager;
import com.rj.util.JsonUtil;

import java.net.CookieManager;
import java.net.CookieStore;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 公共插件接口
 *
 * @author YFX_RANLUBO
 * @date 2025/01/07 11:40
 **/
public interface CommonPlugin<In, Out> {
    /**
     * 创建插件
     */
    void doCreate();

    /**
     * 组件执行完成
     */
    void doDestroy();

    /**
     * 输入参数处理
     *
     * @param inputParam
     */
    void handleInputParam(In inputParam);

    /**
     * 业务执行
     */
    void businessExecute();

    /**
     * 输出参数处理
     *
     * @param outputParam
     */
    void handleOutputParam(Out outputParam);

    /**
     * 业务结果返回处理
     */
    void result();


    public static void main(String[] args) {
        //
        ScheduledThreadPoolExecutor scheduledExecutor = ThreadUtil.createScheduledExecutor(10);
        //for (int i = 0; true; i++){
        scheduledExecutor.execute(() -> {
        //new Thread(()->{
                System.out.println("start");
                HttpUtil.closeCookie();
                HttpRequest httpRequest = HttpRequest.of("https://etax.guizhou.chinatax.gov.cn:8443/mhzx/api/mh/bqxx/getMhsydbBqxx");
                HttpResponse execute = httpRequest.execute();
                try {
                    System.out.println(JsonUtil.toString(execute.getCookies())+"__"+execute.body());
                }catch (Exception e){
                    System.out.println(e.getMessage());
                }
          });
        //}).start();
            ThreadUtil.sleep(1,
                    TimeUnit.HOURS);
        //}


    }

}
